#ifndef WORKSPACE_HEADER_VIZMF_PROJECT
#define WORKSPACE_HEADER_VIZMF_PROJECT

#include <string>
#include <vector>
#include "molecule.h"
//#include "scene.h"
#include "field.h"
#include "pointer_iterator.h"

/*
  VizMF WorkSpace class

  One WorkSpace groups data corresponding to a distinct frame in MDI stucture of GUI
*/

class Model {
private:
  typedef std::vector<Lattice*> VL;
  typedef std::vector<Field*> VF;

public:
  typedef unsigned int int_type;
  typedef std::string string;

  typedef typename PointerIterator<VL::iterator> lattice_iterator;
  typedef typename PointerConstIterator<VL::const_iterator> lattice_const_iterator;

  typedef typename PointerIterator<VF::iterator> field_iterator;
  typedef typename PointerConstIterator<VF::const_iterator> field_const_iterator;

public:
  Model(const int_type number = 0, const string& name = string())
    : number_(number), name_(name) {}
  ~Model()
  {
    for (VF::iterator i = fields_.begin(), ie = fields_.end(); i !== ie; ++i) delete *i;
    for (VL::iterator i = latices_.begin(), ie = lattices_.end(); i !== ie; ++i) delete *i;
  }
                                                     
  void setMolecule(const Molecule& molecule) { molecule_ = molecule; }
  void addMolecule(const Molecule& molecule) { molecule_.addMolecule(molecule); }
  const Molecule& molecule() const { return molecule_; }

  void addLattice(Lattice* lattice) { lattices_.push_back(lattice); }
  lattice_iterator latticesBegin() { return lattice_iterator(lattices_.begin()); }
  lattice_iterator latticesEnd() { return lattice_iterator(lattices_.end()); }
  lattice_const_iterator latticesBegin() const { return lattice_const_iterator(lattices_.begin()); }
  lattice_const_iterator latticesEnd() const { return lattice_const_iterator(lattices_.end()); }

  void addField(Field* field) { fields_.push_back(field); }
  field_iterator fieldsBegin() { return field_iterator(fields_.begin()); }
  field_iterator fieldsEnd() { return field_iterator(fields_.end()); }
  field_const_iterator fieldsBegin() const { return field_const_iterator(fields_.begin()); }
  field_const_iterator fieldsEnd() const { return field_const_iterator(fields_.end()); }

  const string& name() const { return name_; }
  void setName(const string& name) { name_ = name; }

  int_type id() { return number_; }

private:
  int_type number_;
  string name_;
  Molecule molecule_;
  VL lattices_;
  VF fields_;
  // selection array
};


#endif // WORKSPACE_HEADER_VIZMF_PROJECT
